package com.yunti.springboot.controller;


import com.yunti.springboot.annotation.Log;
import com.yunti.springboot.annotation.Permission;
import com.yunti.springboot.service.SubItemService;
import com.yunti.springboot.vo.Result;
import com.yunti.springboot.vo.req.SubItemReq;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ytt
 * @since 2023-12-13
 */
@RestController
@RequestMapping("/subItem")
public class SubItemController {
    @Resource
    SubItemService service;
    @ResponseBody
    @PostMapping(value = "/page")
    public Result findPage(@RequestBody SubItemReq req) {
        return service.findPage(req);
    }

    @Log
    @ResponseBody
    @Permission({"superAdmin"})
    @PostMapping(value = "/edit")
    public Result edit(@Validated(SubItemReq.edit.class) @RequestBody SubItemReq req) {
        return service.edit(req);
    }

    @Log
    @ResponseBody
    @Permission({"superAdmin"})
    @PostMapping(value = "/add")
    public Result add(@Validated(SubItemReq.add.class) @RequestBody SubItemReq req) {
        return service.add(req);
    }

    @Log
    @ResponseBody
    @Permission({"superAdmin"})
    @PostMapping(value = "/del")
    public Result del(@Validated(SubItemReq.del.class) @RequestBody SubItemReq req) {
        return service.del(req);
    }
}
